package com.bh.controller;

import com.bh.pojo.entry.Menu;
import com.bh.pojo.vo.UserVO;
import com.bh.service.MenuService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
@RequestMapping("/menu")
public class MenuController {

    @Autowired
    private MenuService menuService;

    @RequestMapping("/findAll")
    public String findAll(
            @RequestParam(required = false,defaultValue = "1") Integer pageNum,
            @RequestParam(required = false,defaultValue = "1")Integer pageSize, Model model, String  likename){
        PageHelper.startPage(pageNum,pageSize);
        List<Menu> menuList=menuService.findAll(likename);
        PageInfo<Menu> menuInfo = new PageInfo<>(menuList);
        model.addAttribute("menuInfo",menuInfo);
        model.addAttribute("likename",likename);
        return "menu_list";
    }
}
